package com.sjx.boundarycallback.ui;

import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.sjx.boundarycallback.R;
import com.sjx.boundarycallback.databinding.ActivityDialogBinding;
import com.sjx.boundarycallback.dialog.CenterDialog;


public class DialogActivity extends AppCompatActivity {

    private ActivityDialogBinding mBinding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_dialog);
        mBinding.btnShowDialog.setOnClickListener(v -> {
            CenterDialog dialog = new CenterDialog(this);
            Window window = dialog.getWindow();
            //此处设置位置窗体大小，
            window.setGravity(Gravity.BOTTOM);
            window.getDecorView().setPadding(0, 0, 0, 0);
            WindowManager.LayoutParams lp = window.getAttributes();
            lp.width = WindowManager.LayoutParams.MATCH_PARENT;
            lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
            window.setAttributes(lp);
            dialog.show();
        });
    }
}